update userinfo_update

FFIB 2 年之前
父節點
當前提交
9e586e446e
共有 1 個文件被更改,包括 14 次插入6 次删除
  1. 14 6
      api/antigen_views.py

+ 14 - 6
api/antigen_views.py

@@ -3,6 +3,7 @@
3 3
 from __future__ import division
4 4
 
5 5
 from django.db.models import Q
6
+from django_logit import logit
6 7
 from django_response import response
7 8
 from TimeConvert import TimeConvert as tc
8 9
 
@@ -10,7 +11,7 @@ from account.models import UserInfo
10 11
 from equipment.models import AntigenMeasureLogInfo, IsolationPointUserInfo, IsolationPointInfo
11 12
 from utils.error.errno_utils import IsolationPointStatusCode
12 13
 
13
-
14
+@logit(body=True)
14 15
 def upload_antigen(request):
15 16
     unionid = request.POST.get('unionid', '')
16 17
     macid = request.POST.get('macid', '')
@@ -55,6 +56,7 @@ def get_antigen_screen_data(point_id):
55 56
     return ipuis
56 57
 
57 58
 
59
+@logit(body=True)
58 60
 def get_antigen_screen_result(request):
59 61
     point_id = request.POST.get('point_id', '')
60 62
 
@@ -63,16 +65,22 @@ def get_antigen_screen_result(request):
63 65
     return response(data=screen_data)
64 66
     
65 67
 
68
+@logit(body=True)
66 69
 def userinfo_update(request):
67 70
     unionid = request.POST.get('unionid', '')
68 71
     phone = request.POST.get('phone', '')
69
-    identifty_card_number = request.POST.get('identifty_card_number', '')
70
-    identifty_card_name = request.POST.get('identifty_card_name', '')
72
+    identify_card_number = request.POST.get('identify_card_number', '')
73
+    identify_card_name = request.POST.get('identify_card_name', '')
71 74
 
72
-    if unionid:
75
+    if not unionid:
73 76
         return response(40001, 'Unionid Cannot Be Empty', 'Unionid 不能为空')
74 77
 
75
-    UserInfo.objects.filter(unionid=unionid).update(phone=phone, identifty_card_name=identifty_card_name, identifty_card_number=identifty_card_number)
76
-    IsolationPointUserInfo.objects.filter(unionid=unionid).update(phone=phone, name=identifty_card_name)
78
+    user, _ = UserInfo.objects.get_or_create(unionid=unionid)
79
+    user.phone = phone
80
+    user.identify_card_name = identify_card_name
81
+    user.identify_card_number = identify_card_number
82
+    user.save()
83
+
84
+    IsolationPointUserInfo.objects.filter(unionid=unionid).update(phone=phone, name=identify_card_name)
77 85
 
78 86
     return response(200, '', 'UserInfo Update Success', '用户个人信息更新成功')